package cn.zhc.com.http;


import android.content.Context;

import cn.zhc.com.base.BaseForm;
import cn.zhc.com.http.listener.OnHttpRequestListener;
import cn.zhc.com.utils.UtilsBase64;
import rx.Observable;

/**
 * Created by zhouhongchun on 2017/8/2.
 * 建议主项目重新继承该类
 */

public class HttpManager {

    /**
     * URL基地址
     */
    public static String BaseUrl = "http://192.168.1.216:8080/findCar/";

    /**
     * 所有网络请求的url,
     */
    public static final String[] URLS = {
            BaseUrl + "index.php?",

    };
    /**
     * *************************** 使用案例 Start 建议主项目重新继承该类 **********************************
     */
    /**
     *
     * @param context
     * @param needCache
     * @param uid
     * @param mOnHttpRequestListener
     */
    public static void requestServer1(Context context,boolean needCache, String uid, OnHttpRequestListener mOnHttpRequestListener) {
        try {

            String IDUrl = URLS[0];
            String params = new BaseForm()
                    .addParam("uid", uid)
                    +"";
            String dataPost = UtilsBase64.encodeUTF8(params);
            String timestamp = System.currentTimeMillis()+"";
            Observable mObservable = UtilsHttp.initOkHttp().requestServer1(timestamp,dataPost);
            String cacheTag = UtilsHttp.dealHttpCache(context,needCache,IDUrl,params,mOnHttpRequestListener);
            UtilsHttp.toSubscribe(context, mObservable, IDUrl, mOnHttpRequestListener, needCache, cacheTag);
        }catch (Exception e){
            e.printStackTrace();
        }

    }
    /**
     * *************************** 使用案例 End 建议主项目重新继承该类 **********************************
     */



}
